import { useState, useEffect } from 'react';

function getCityList(params: any): any {
  return new Promise((resolve) => {
    window.setTimeout(() => {
      resolve({
        success: true,
        data: [1,2,3]
      })
    }, 3000);
  })
}
const useCityList = (params: any) => {
  const [cityList, setList] = useState([]);
  const [loading, setLoading] = useState(true)
  const getList = async () => {
    console.log("getList.....", params);
    const { success, data } = await getCityList(params);
    if (success) setList(data);
    setLoading(false)
  };
  useEffect(() => {
    getList();
  // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);
  return {
    cityList,
    loading
  };
};
export default useCityList;
